<#--
* 正元协同办公系统J2EE版
* 声明：金华正元计算机工程有限公司版权所有,
* 名称：sysUserform.ftl
* 功能：编辑本人信息。
* 来源：本页由sysUserShow.ftl(也可以用action来表达：sysUserAction!add(modify).shtml)中人员列表界面跳转过来。
*
* 去向：
*    1、列表：到sysUserShow.ftl页面
*	修改日志：是修改历史记录列表，每条修改记录应包括修改日期、
*	修改者及修改内容简述。
*	姓名：    徐国华    时间：2006-6-22    内容：参照和页面注释
*			项春科	时间：2007-9-28	  内容：改成新框架
*			项春科	时间：2009-3-25	内容: 修改宏
-->
<#include "/common/pager_style/commonForm.ftl" encoding="UTF-8">
<script type="text/javascript" src="${request.contextPath}/js/jquery/zyplugin/selectutils/jquery.selectutils.js"></script>

<#-- 定义有哪些按钮 reset:重写 back:返回 -->
<#if editState="modify">
	<#assign buttonsName = {"save":"保存","reset":"重置","back":"返回"}>
<#else>
	<#assign buttonsName = {"modify":"修改","copy":"复制","back":"返回"}>
</#if>


<script language="javascript">
<!--
	var actName="sysUserAction";
	var domainName="sysUser";

	function checkForm()
	{
	   // var strMsg = "";
		//类型：AlphaNumeric,Date,Email,Empty,Numeric,Money,PostalCode,Url
		//strMsg = strMsg + Validate( "sysUser.sysDept.id", "部门","NotEmpty");
		//strMsg = strMsg + Validate( "sysUser.userCode", "编码","NotEmpty|AlphaNumeric");
		//strMsg = strMsg + Validate( "sysUser.userName", "姓名","NotEmpty");
		//strMsg = strMsg + Validate( "sysUser.sysDept.deptName", "所属部门名称","NotEmpty");

		//strMsg = strMsg + ValidateMinLength( "sysUser.password", "新密码",2);

		//strMsg = strMsg + Validate( "sysUser.password", "新密码","NotEmpty");

		//strMsg = strMsg + Validate( "sysUser.sortNum", "人员顺序","NotEmpty");
		//strMsg = strMsg + Validate( "sysUser.sortNum", "人员顺序","Numeric");
		//if( strMsg != "" )
		//{
		//	alert( strMsg );
		//	return false;
		//}
		//else if( document.getElementById("sysUser.password").value !=
		//document.getElementById("password").value )
		//{
		//	document.getElementById("sysUser.password").value = "";
		//	document.getElementById("password").value = "";
		//	alert( "密码输入不一致，请重新输入" );
		//	return false;
		//}else{
			$("option",$("#roleIds")).attr("selected",true);	// 将已选列表框中的元素全部选中，以便将数据提交到action中
			$("option",$("#groupIds")).attr("selected",true);	// 将已选列表框中的元素全部选中，以便将数据提交到action中
		//	return true;
		//}
		//return $("form").validationEngine({returnIsValid:true});
	}
	$(function(){
		$("form").validationEngine();


		selectManageScope();

		$("#sysUser\\.caid").on("change",function(){
			var val=$(this).val();
			$(this).val(val.trim());
			}
		);
	});


	//选择管理范围
	function selectManageScope(){

		//根据权限类型，选择 对象值的文本框是否显示
		var permLeadType = "${permLeadType?if_exists}";
		setEleVisible("permLeadTxt",permLeadType);
		$(":radio[name=permLeadType]").prop("checked",false);
		$(":radio[name=permLeadType][value=" + permLeadType + "]").prop("checked",true);


		//点击权限类型时，控制显示隐藏
		$(":radio[name=permLeadType]").click(function(){
			var v = $(":radio[name=permLeadType]:checked").val();
			setEleVisible("permLeadTxt",v);
		});


		//选择对象
		$("#clickScope").click(function(){
			var v = $(":radio[name=permLeadType]:checked").val();

			<#if  currentUser.orgId?exists && currentUser.orgId == 0>
				if(v=="USER")
					openReferenceM("sysUser","orgUserTree","permLeadTxt=value2&permLeadValue=value1");
				else if(v=="DEPT")
					openReferenceM("SysDept","orgDeptTree","permLeadTxt=value2&permLeadValue=value1");
				else if(v=="GROUP")
					openReferenceM("PermUsergroup","orgGroupTree","permLeadTxt=value2&permLeadValue=value1");

			<#else>
				if(v=="USER")
					openReferenceM("SysDept","dept3","permLeadTxt=value2&permLeadValue=value1");
				else if(v=="DEPT")
					openReferenceM("SysDept","dept4","permLeadTxt=value2&permLeadValue=value1");
				else if(v=="GROUP")
					openReferenceM("PermUsergroup","listGroup","permLeadTxt=value4&permLeadValue=value1");

			</#if>
			return	false;
		});
	}



	//根据状态值，设置对象是否显示。"0"时隐藏
	function	setEleVisible(eleId,status){
		if(status=="0"){
			$("#" + eleId).hide();
		}else{
			$("#" + eleId).show();
		}
	}

	function opt_copy(){
		$("form").eq(0).attr("action",actName + '!copyUser.shtml');
		$("form").eq(0).submit();
	}


//-->
</script>
</head>
<body scroll="auto">
<form name="sysUserForm" action="" method="post" onsubmit="return checkForm();">
<div id="mainDiv">
		<div id="topDiv">
<#-- 生成按钮 -->
<#include "/common/pager_style/pageButtons.ftl" encoding="UTF-8">
</div><div id="centerDiv">
		<div id="body">
<table class="tbl">
	<caption>用户信息编辑</caption>
    <input type="hidden" id="id" name="id" value="${(sysUser.id)?if_exists}">
    <input type="hidden" id="sysUser.id" name="sysUser.id" value="${(sysUser.id)?if_exists}">
	<input type="hidden" name="cur_orgDeptRootId" 			id="cur_orgDeptRootId" 			value="${(currentUser.orgDeptRootId)?if_exists}"/>
    <input type="hidden" name="cur_orgDeptRootName" 			id="cur_orgDeptRootName" 			value="${(currentUser.orgDeptRootName)?if_exists}"/>

	<!-- 数据录入 -->
	<tbody>
	  <@pEdit.pageEditText
	  			label="编码 *"
	  			pageState="${editState}"
	  			endTR="false"
				validate="rule[notEmpty,alphaNumeric]"
	  			attName="sysUser.userCode"
	  			attValue="${(sysUser.userCode)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="CA编码 "
	  			pageState="${editState}"
	  			beginTR="false"
	  			attName="sysUser.caid"
	  			attValue="${(sysUser.caid)?if_exists}"/>
	 	<@pEdit.pageEditText
		  		label="人员顺序 *"
		  		pageState="${editState}"
		  		endTR="false"
				validate="rule[notEmpty,numeric]"
		  		attName="sysUser.sortNum"
		  		attValue="${(sysUser.sortNum)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="姓名 *"
	  			pageState="${editState}"
	  			beginTR="false"
				validate="rule[notEmpty]"
	  			attName="sysUser.userName"
	  			attValue="${(sysUser.userName)?if_exists}"/>
<#if editState="modify">
	  <@pEdit.pageEditPassword
	  			label="密码 *"
	  			pageState="${editState}"
	  			endTR="false"
				validate="rule[notEmpty]"
	  			attName="sysUser.password"
	  			attValue="${(sysUser.password)?if_exists}"/>
	  <@pEdit.pageEditPassword
	  			label="确认密码 *"
	  			pageState="${editState}"
	  			beginTR="false"
				validate="rule[confirm[sysUser\\.password]]"
	  			attName="password"
	  			attValue="${(sysUser.password)?if_exists}"/>
</#if>
		<@pEdit.pageEditText
				label="领导秘书"
				pageState="${editState}"
				endTR="false"
				attName="userName"
				showRefer="true"
				referJS="openReference('SysDept','deptUserAll','sysUser.secUser=value1&userName=value2',null,null,null,'${(currentUser.orgDeptRootId)?if_exists}');"
				inputReadOnly="true"
				attValue="${(userName)?if_exists}">
				<input type="hidden" id="sysUser.secUser" name="sysUser.secUser" value="${(sysUser.secUser)?if_exists}">
		</@pEdit.pageEditText>
		<@pEdit.pageEditTextDate
		  		label="出生年月"
		  		pageState="${editState}"
				beginTR="false"
		  		attName="sysUser.birthday"
		  		attValue="${(sysUser.birthday)?if_exists}"
		  		showsTime="false"/>
		<#if currentUser?exists && currentUser.isSuperAdmin?exists && currentUser.isSuperAdmin>
			<@pEdit.pageEditText
					label="部门 *"
					pageState="${editState}"
					endTR="false"
					validate="rule[notEmpty]"
					attName="sysUser.sysDept.deptName"
					showRefer="true"
					referJS="openReference('SysDept','deptAll','sysUser.sysDept.deptName=value2&sysUser.sysDept.id=value1',null,null,null,'${(currentUser.orgDeptRootId)?if_exists}');"
					inputReadOnly="true"
					attValue="${(sysUser.sysDept.deptName)?if_exists}">
					<input type="hidden" id="sysUser.sysDept.id" name="sysUser.sysDept.id" value="${(sysUser.sysDept.id)?if_exists}">
			</@pEdit.pageEditText>
		<#else>
			<@pEdit.pageEditText
					label="部门 *"
					pageState="${editState}"
					endTR="false"
					validate="rule[notEmpty]"
					attName="sysUser.sysDept.deptName"
					showRefer="true"
					referJS="openReference('SysDept','dept4','sysUser.sysDept.deptName=value2&sysUser.sysDept.id=value1',null,null,null,'${(currentUser.orgDeptRootId)?if_exists}');"
					inputReadOnly="true"
					attValue="${(sysUser.sysDept.deptName)?if_exists}">
					<input type="hidden" id="sysUser.sysDept.id" name="sysUser.sysDept.id" value="${(sysUser.sysDept.id)?if_exists}">
			</@pEdit.pageEditText>
		</#if>

	  	<@pEdit.pageEditText
		  		label="职务 "
		  		pageState="${editState}"
		  		beginTR="false"
		  		attName="sysUser.duty"
		  		attValue="${(sysUser.duty)?if_exists}"/>
	  		<#--
	  	<@pEdit.pageEditText
		  		label="年龄 "
		  		pageState="${editState}"
		  		attName="sysUser.age"
		  		attValue="${(sysUser.age)?if_exists}"/>
	  		-->
	    <@pEdit.pageEditSelectUserValue
	    		label="学历"
		 		pageState="${editState}"
		 		endTR="false"
		  		attName="sysUser.edut"
		  		attValue="${(sysUser.edut)?if_exists}"
		  		cssStyle="width:150px;"
				optionSource={"小学":"小学","初中":"初中","高中":"高中",
								"中技":"中技","职高":"职高","中专":"中专",
								"大专":"大专","本科":"本科","硕士":"硕士",
								"博士":"博士"}
				defaultSelect=7	/>
	    <@pEdit.pageEditSelectUserValue
	    		label="职称"
		 		pageState="${editState}"
		 		beginTR="false"
		  		attName="sysUser.position"
		  		attValue="${(sysUser.position)?if_exists}"
		  		cssStyle="width:150px;"
				optionSource={"高级":"高级","中级":"中级","初级":"初级",
								"其他":"其他"}
				defaultSelect=1/>
	  <@pEdit.pageEditText
	  			label="家庭住址"
	  			pageState="${editState}"
	  			endTR="false"
	  			attName="sysUser.address"
	  			attValue="${(sysUser.address)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="家里电话"
	  			pageState="${editState}"
	  			beginTR="false"
	  			attName="sysUser.homeTel"
	  			attValue="${(sysUser.homeTel)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="手机"
	  			pageState="${editState}"
	  			endTR="false"
	  			attName="sysUser.mobile"
	  			attValue="${(sysUser.mobile)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="办公室电话"
	  			pageState="${editState}"
	  			beginTR="false"
	  			attName="sysUser.officeTel"
	  			attValue="${(sysUser.officeTel)?if_exists}"/>
	  <#--
	  <@pEdit.pageEditText
	  			label="小灵通"
	  			pageState="${editState}"
	  			attName="sysUser.ut"
	  			attValue="${(sysUser.ut)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="个人主页"
	  			pageState="${editState}"
	  			attName="sysUser.ownPage"
	  			attValue="${(sysUser.ownPage)?if_exists}"/>
	  <@pEdit.pageEditText
	  			label="电子邮箱"
	  			pageState="${editState}"
	  			attName="sysUser.email"
	  			attValue="${(sysUser.email)?if_exists}"/>
	  			-->
	  <@pEdit.pageEditText
	  			label="批示编号前缀"
	  			pageState="${editState}"
	  			endTR="false"
	  			attName="sysUser.psPrefix"
	  			attValue="${(sysUser.psPrefix)?if_exists}"/>
	<@pEdit.pageEditRadioUserValue
				label="是否停用 *"
	  			pageState="${editState}"
	  			beginTR="false"
		  		attName="sysUser.isStop"
		  		attValue="${(sysUser.isStop)?if_exists}"
		  		optionSource={"0":"可用","1":"停用"}
		  		defaultSelect=0 />
	<@pEdit.pageEditRadioUserValue
				label="是否接收短信 *"
	  			pageState="${editState}"
	  			endTR="false"
		  		attName="sysUser.isReceive"
		  		attValue="${(sysUser.isReceive)?if_exists}"
		  		optionSource={"0":"否","1":"是"}
		  		defaultSelect=1 />
	  <@pEdit.pageEditText
	  			label="备注"
	  			pageState="${editState}"
	  			beginTR="false"
	  			attName="sysUser.memo"
	  			attValue="${(sysUser.memo)?if_exists}"/>
	  <#if currentUser?exists && currentUser.isSuperAdmin?exists && currentUser.isSuperAdmin>
			<@pEdit.pageEditText
					label="附属部门 "
					pageState="${editState}"
					endTR="false"
					attName="sysUser.subDeptNames"
					showRefer="true"
					referJS="openReferenceM('SysDept','deptAll','sysUser\\.subDeptNames=value2&sysUser\\.subDeptIds=value1',null,null,null,'${(currentUser.orgDeptRootId)?if_exists}');"
					inputReadOnly="true"
					attValue="${(sysUser.subDeptNames)?if_exists}">
					<input type="hidden" id="sysUser.subDeptIds" name="sysUser.subDeptIds" value="${(sysUser.subDeptIds)?if_exists}">
			</@pEdit.pageEditText>
		<#else>
			<@pEdit.pageEditText
					label="附属部门 "
					pageState="${editState}"
					endTR="false"
					attName="sysUser.subDeptNames"
					showRefer="true"
					referJS="openReferenceM('SysDept','dept4','sysUser\\.subDeptNames=value2&sysUser\\.subDeptIds=value1',null,null,null,'${(currentUser.orgDeptRootId)?if_exists}');"
					inputReadOnly="true"
					attValue="${(sysUser.subDeptNames)?if_exists}">
					<input type="hidden" id="sysUser.subDeptIds" name="sysUser.subDeptIds" value="${(sysUser.subDeptIds)?if_exists}">
			</@pEdit.pageEditText>
		</#if>
		<@pEdit.pageEditRadioUserValue
				label="主部门是否仅本人提取 "
	  			pageState="${editState}"
	  			beginTR="false"
		  		attName="sysUser.isMyself"
		  		attValue="${(sysUser.isMyself)?if_exists}"
		  		optionSource={"0":"否","1":"是"}
		  		defaultSelect=0 />
		<#if currentUser?exists && currentUser.isSuperAdmin?exists && currentUser.isSuperAdmin>
		<@pEdit.pageEditText
	  			label="易和对接唯一编码"
	  			pageState="${editState}"
	  			endTD="false"
	  			attName="sysUser.yhUniqueCode"
	  			attValue="${(sysUser.yhUniqueCode)?if_exists}"
	  			colSpanNum="3"/>
	  	<@pEdit.pageEditText
	  			label="易和排序号"
	  			pageState="${editState}"
	  			endTD="false"
	  			attName="sysUser.yhOrderby"
	  			attValue="${(sysUser.yhOrderby)?if_exists}"
	  			colSpanNum="3"/>
	  	<@pEdit.pageEditText
	  			label="数梦UserId"
	  			pageState="${editState}"
	  			endTD="false"
	  			attName="sysUser.ddUserid"
	  			attValue="${(sysUser.ddUserid)?if_exists}"
	  			colSpanNum="3"/>
	  	</#if>
	  	
	<!-- 数据录入结束 -->
	</tbody>
</table>

<table class="tbl">
	<tr>
		<th colspan="2">
			<label>最多一星期</label>
		</th>
	</tr>
	<@pEdit.pageEditText
				label="分管单位"
				pageState="${editState}"
				endTR="false"
				attName="subOrgNames"
				showRefer="true"
				referJS="openReferenceM('sysOrg','getOrg','subOrgNames=value2&subOrgIds=value1',null,null,null,null);"
				inputReadOnly="true"
				attValue="${(subOrgNames)?if_exists}">
				<input type="hidden" id="subOrgIds" name="subOrgIds" value="${(subOrgIds)?if_exists}">
		</@pEdit.pageEditText>
</table>

<table class="tbl">
	<tr>
		<th colspan="2">
			<label>直接下属人员范围</label>
		</th>

	</tr>
	<#if currentUser?exists && currentUser.isSuperAdmin?exists && currentUser.isSuperAdmin>
	<@pEdit.pageEditSelectForUserRangeType
    		label="下属人员类型"
	 		pageState="${editState}"
	 		JS="onchange=onSelectTypeChange(this,'permLeadValue','permLeadTxt');return false;"
	  		attName="permLeadType"
	  		attValue="${(permLeadType)?if_exists}"
	  		cssStyle="width:150px;"
			rangeType="ORG_ALL"/>
	<#elseif currentUser?exists && (currentUser.orgId==5 || currentUser.orgId==7)>
	<@pEdit.pageEditSelectForUserRangeType
    		label="下属人员类型"
	 		pageState="${editState}"
	 		JS="onchange=onSelectTypeChange(this,'permLeadValue','permLeadTxt');return false;"
	  		attName="permLeadType"
	  		attValue="${(permLeadType)?if_exists}"
	  		cssStyle="width:150px;"
			rangeType="ORG"/>
	<#else>
	<@pEdit.pageEditSelectForUserRangeType
    		label="下属人员类型"
	 		pageState="${editState}"
	 		JS="onchange=onSelectTypeChange(this,'permLeadValue','permLeadTxt');return false;"
	  		attName="permLeadType"
	  		attValue="${(permLeadType)?if_exists}"
	  		cssStyle="width:150px;"
			rangeType="ORG_ONLY"/>
	</#if>
	<@pEdit.pageEditTextarea
			label="人员范围"
			inputReadOnly="true"
			pageState="${editState}"
			validate="rule[funcCall[permLeadType]]"
			attName="permLeadTxt"
			showRefer="true"
			referJS="selectUsersForType('permLeadType','permLeadValue','permLeadTxt');return false;"
			height="50px;"
			colSpanNum="1"
			cssStyle="height:100%;width:100%;"
			attValue="${(permLeadTxt)?if_exists}">
			<input type="hidden" id="permLeadValue" name="permLeadValue" value="${(permLeadValue)?if_exists}">
	</@pEdit.pageEditTextarea>
</table>

<table class="tbl">
	<tr>
		<th>
			<label for="roleIds">所属角色</label>
		</th>
		<th>
			<label for="groupIds">所属岗位</label>
		</th>
	</tr>
	<tr>
	<!-- 所属角色  -->
	    <@pEdit.pageEditSelectMany2
		 		pageState="${editState}"
				validate="rule[notEmpty]"
		  		attName="roleIds"
		  		attValue="${(sysUser.permRoleassigns)?if_exists}"
		  		cssStyle="width:150px;"
				optionSource=permUserroles?if_exists
				optionValue="id"
				optionLabel="roleName"
				dataSource=sysUser.permRoleassigns?if_exists
				dataValue1="permUserrole"
				dataValue2="id"
				dataLabel1="permUserrole"
				dataLabel2="roleName"/>

		<!--	所属岗位	validate="rule[notEmpty]"	-->
	    <@pEdit.pageEditSelectMany2
		 		pageState="${editState}"
		  		attName="groupIds"
		  		attValue="${(sysUser.permGroupassigns)?if_exists}"
		  		cssStyle="width:150px;"
				optionSource=permUsergroups?if_exists
				optionValue="id"
				optionLabel="groupName"
				dataSource=sysUser.permGroupassigns?if_exists
				dataValue1="permUsergroup"
				dataValue2="id"
				dataLabel1="permUsergroup"
				dataLabel2="groupName"/>
	</tr>
</table>
<div class="notes">
	说明：此是对系统用户进行录入编辑,包含了个人所属的全部信息,其中编码、姓名、部门、密码、电子邮箱、人员顺序为必填属性
</div>
</div></div>
		</div>
</form>
<!--<input type="button" value="加载" onclick="window.location.href='sysUserAction!testFile.shtml'">-->
<!--<input type="button" value="导出" onclick="batchExport();">-->
</body>
</html>